package icu.zqyhdm.commonService.controller;

import icu.zqyhdm.commonService.service.OssService;
import icu.zqyhdm.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * @Description
 * @Author lifu
 * @Date 2021/7/7 21:33
 */
@Api(tags = "文件上传接口")
@RestController
@RequestMapping(value = "/api/common-service/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 上传文件到阿里云oss
     */
    @ApiOperation(value = "上传文件到阿里云oss")
    @PostMapping(value = "/fileUpload")
    public Result fileUpload(@RequestParam(value = "file") MultipartFile multipartFile, @RequestParam("fileUrl")String fileUrl){
        String url = ossService.upload(multipartFile,fileUrl);
        return Result.ok(url);
    }
}
